package com.lyrpx.mapper;

import com.lyrpx.pojo.Worker;
import org.apache.ibatis.annotations.*;

public interface WorkerMapper {
    //按id查询tb_worker表记录

    @Select("select * from tb_worker where id = #{id}")
    Worker selectWorker(int id);

    //向tb_worker表插入新记录
    @Insert("insert into tb_worker(name,age,sex,worker_id)"
            + "values(#{name},#{age},#{sex},#{worker_id})")
    int insertWorker(Worker worker);
    //按id修改tb_worker表的name及age字段值

    @Update("update tb_worker set name = #{name},age = #{age} "
            + "where id = #{id}")
    int updateWorker(Worker worker);

    //按id删除tb_worker表记录

    @Delete("delete from tb_worker where id = #{id}")
    int deleteWorker(int id);

    //按id和name两个字段查询tb_worker表记录
    @Select("select * from tb_worker where id = #{param01} " +
            "and name = #{param02}")
    Worker selectWorkerByIdAndName(@Param("param01") int id,
                                   @Param("param02") String name);
}
